package com.yin.myproject.thread.spinlock;

/**
 * @author Eason
 * @create 2018-03-07 10:20
 **/
public class Main {
    private static TimeCost timeCost = new TimeCost(new TTASLock());
//    private static TimeCost timeCost = new TimeCost(new TASLock());

    public static void method() {
        timeCost.lock();
        //int a = 10;
        timeCost.unlock();
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            Thread t = new Thread(() -> method());
            t.start();
        }
        System.out.println(timeCost.toString() + " time avg is " + timeCost.getAvg() + " ns");
    }
}
